using System;
using System.Collections;
using Rdl;

namespace GTame.ReportParser
{

    public class QueryType
    {

        private string _CommandText;
        private Rdl.QueryTypeCommandType _CommandType;
        private string _DataSourceName;
        private GTame.ReportParser.QueryParametersType _QueryParameters;
        private System.Nullable<uint> _Timeout;

        public string CommandText
        {
            get
            {
                return _CommandText;
            }
            set
            {
                _CommandText = value;
            }
        }

        public Rdl.QueryTypeCommandType CommandType
        {
            get
            {
                return _CommandType;
            }
            set
            {
                _CommandType = value;
            }
        }

        public string DataSourceName
        {
            get
            {
                return _DataSourceName;
            }
            set
            {
                _DataSourceName = value;
            }
        }

        public GTame.ReportParser.QueryParametersType QueryParameters
        {
            get
            {
                if (_QueryParameters == null)
                    _QueryParameters = new GTame.ReportParser.QueryParametersType();
                return _QueryParameters;
            }
            set
            {
                _QueryParameters = value;
            }
        }

        public System.Nullable<uint> Timeout
        {
            get
            {
                return _Timeout;
            }
            set
            {
                _Timeout = value;
            }
        }

        public QueryType()
        {
            _Timeout = new System.Nullable<uint>[]();
        }

        public Rdl.QueryType Write()
        {
            Rdl.QueryType queryType = new Rdl.QueryType();
            System.Collections.ArrayList arrayList1 = new System.Collections.ArrayList();
            System.Collections.ArrayList arrayList2 = new System.Collections.ArrayList();
            if (_CommandText != null)
            {
                arrayList1.Add(_CommandText);
                arrayList2.Add(1);
            }
            arrayList1.Add(_CommandType);
            arrayList2.Add(2);
            if (_DataSourceName != null)
            {
                arrayList1.Add(_DataSourceName);
                arrayList2.Add(3);
            }
            if (_QueryParameters != null)
            {
                arrayList1.Add(_QueryParameters.Write());
                arrayList2.Add(4);
            }
            if (_Timeout.get_HasValue())
            {
                arrayList1.Add(_Timeout);
                arrayList2.Add(5);
            }
            queryType.Items = arrayList1.ToArray();
            queryType.ItemsElementName = (Rdl.ItemsChoiceType2[])arrayList2.ToArray(typeof(Rdl.ItemsChoiceType2));
            arrayList2 = arrayList1 = null;
            return queryType;
        }

    } // class QueryType

}

